/*
 * @Author: SeonHu
 * @Date: 2025-09-16 14:44:19
 * @LastEditors: SeonHu
 * @LastEditTime: 2025-09-23 15:33:22
 * @FilePath: \bg-vben\src\api\report\print.ts
 * @Description:
 * Copyright © 2020-2025 SANQING Corporation, All rights reserved.
 */
import type { PrintTemplateUserDtoSimple, PrintUserDtoSimple } from './admin/print/model';
import type { PrintReportRequestDto } from './model/print';

import type { ErrorMessageMode } from '#/request';

import { request } from '@/utils/request/axios';

/** 报表模块打印URL枚举 */
enum Api {
  /** 根据打印编号获取打印模板集合 */
  GetPrintTemplatesById = '/api/rpt/getPrintTemplatesById',
  /** 根据打印编码获取打印模板集合 */
  GetPrintTemplatesByCode = '/api/rpt/getPrintTemplatesByCode',
  /** 取消默认打印 */
  CancelDefaultPrints = '/api/rpt/cancelDefaultPrints',
  /** 设置默认打印 */
  SetDefaultPrints = '/api/rpt/setDefaultPrints',
  /** 获取打印报告文件 */
  GetPrintReportFile = '/api/rpt/getPrintReportFile',
  /** 获取打印报告Base64编码 */
  GetPrintReportBase64 = '/api/rpt/getPrintReportBase64',
}

// #region 根据打印编号获取打印模板集合
/**
 * 根据打印编号获取打印模板集合
 * @param printId 打印编号
 * @param mode 错误消息模型
 */
export function getPrintTemplatesById(printId: bigint | string, mode: ErrorMessageMode = 'message') {
  return request.get(
    {
      url: Api.GetPrintTemplatesById,
      params: { printId },
    },
    {
      errorMessageMode: mode,
    },
  );
}
// #endregion
// #region 根据打印编码获取打印模板集合
/**
 * 根据打印编码获取打印模板集合
 * @param printCode 打印编码
 * @param mode 错误消息模型
 */
export function getPrintTemplatesByCode(printCode: string, mode: ErrorMessageMode = 'message') {
  return request.get(
    {
      url: Api.GetPrintTemplatesByCode,
      params: { printCode },
    },
    {
      errorMessageMode: mode,
    },
  );
}
// #endregion

// #region 取消默认打印
/**
 * 取消默认打印
 * @param dtos 输入DTO
 * @param mode 错误消息模型
 */
export function cancelDefaultPrints(dtos: PrintUserDtoSimple[], mode: ErrorMessageMode = 'message') {
  return request.post(
    {
      url: Api.CancelDefaultPrints,
      params: dtos,
    },
    {
      errorMessageMode: mode,
    },
  );
}
// #endregion
// #region 设置默认打印
/**
 * 设置默认打印
 * @param dtos 输入DTO
 * @param mode 错误消息模型
 */
export function setDefaultPrints(dtos: PrintTemplateUserDtoSimple[], mode: ErrorMessageMode = 'message') {
  return request.post(
    {
      url: Api.SetDefaultPrints,
      params: dtos,
    },
    {
      errorMessageMode: mode,
    },
  );
}
// #endregion

// #region 获取打印报告文件
/**
 * 获取打印报告文件
 * @param dto 请求DTO
 * @param mode 错误消息模型
 */
export function getPrintReportFile(dto: PrintReportRequestDto, mode: ErrorMessageMode = 'message') {
  return request.post(
    {
      url: Api.GetPrintReportFile,
      params: dto,
    },
    {
      errorMessageMode: mode,
    },
  );
}
// #endregion
// #region 获取打印报告Base64编码
/**
 * 获取打印报告Base64编码
 * @param dto 请求DTO
 * @param mode 错误消息模型
 */
export function getPrintReportBase64(dto: PrintReportRequestDto, mode: ErrorMessageMode = 'message') {
  return request.post(
    {
      url: Api.GetPrintReportBase64,
      params: dto,
    },
    {
      errorMessageMode: mode,
    },
  );
}
// #endregion
